typedef struct 
{
    Queue Que1;
    Queue Que2;
} MyStack;
MyStack* myStackCreate() 
{
    MyStack* pst = (MyStack*)malloc(sizeof(MyStack));
    if(pst == NULL)
    {
        perror("malloc fail");
        return NULL;
    }
    QueueInit(&pst->Que1);
    QueueInit(&pst->Que2);
    return pst;
}

void myStackPush(MyStack* obj, int x) 
{
    if(!QueueEmpty(&obj->Que1))
    {
        QueuePush(&obj->Que1,x);
    }
    else
    {
        QueuePush(&obj->Que2,x);
    }
}
 
int myStackPop(MyStack* obj) 
{
    Queue* emptyQ = &obj->Que1;
    Queue* nonemptyQ = &obj->Que2;
    if(!QueueEmpty(&obj->Que1))
    {
        emptyQ = &obj->Que2;
        nonemptyQ = &obj->Que1;
    }
    while(QueueSize(nonemptyQ)>1)
    {
        QueuePush(emptyQ,QueueFront(nonemptyQ));
        QueuePop(nonemptyQ);
    }
		int top = QueueFront(nonemptyQ);
		QueuePop(nonemptyQ);
		return top;
}
int myStackTop(MyStack* obj) 
{
    if(!QueueEmpty(&obj->Que1))
    {
        return QueueBack(&obj->Que1);
    }
    else
    {
        return QueueBack(&obj->Que2);
    }
}
bool myStackEmpty(MyStack* obj)
{
    return QueueEmpty(&obj->Que1)&&QueueEmpty(&obj->Que2);
}
void myStackFree(MyStack* obj) 
{
    QueueDestroy(&obj->Que1);
    QueueDestroy(&obj->Que2);
    free(obj);
}